package org.nanotek;

import java.io.Serializable;
import java.util.Date;
import org.nanotek.util.Base;

@SuppressWarnings("serial")
public class DateBase<K extends Serializable> implements Stampable<Date>, Serializable {

	protected Date dateUpdate;

	protected Date dateInsert;

	protected Date dateCreation;

	public DateBase(Date date){
		this.dateCreation = date;
	}

	public Date getDateUpdate() {
		return dateUpdate;
	}

	public void setDateUpdate(Date dateUpdate) {
		this.dateUpdate = dateUpdate;
	}

	public Date getDateInsert() {
		return dateInsert;
	}

	public void setDateInsert(Date dateInsert) {
		this.dateInsert = dateInsert;
	}


	@Override
	public Date getStamp() {
		return dateCreation;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((dateCreation == null) ? 0 : dateCreation.hashCode());
		result = prime * result
				+ ((dateInsert == null) ? 0 : dateInsert.hashCode());
		result = prime * result
				+ ((dateUpdate == null) ? 0 : dateUpdate.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DateBase other = (DateBase) obj;
		if (dateCreation == null) {
			if (other.dateCreation != null)
				return false;
		} else if (!dateCreation.equals(other.dateCreation))
			return false;
		if (dateInsert == null) {
			if (other.dateInsert != null)
				return false;
		} else if (!dateInsert.equals(other.dateInsert))
			return false;
		if (dateUpdate == null) {
			if (other.dateUpdate != null)
				return false;
		} else if (!dateUpdate.equals(other.dateUpdate))
			return false;
		return true;
	}

}
